package com.example.demo.controller;


import com.example.demo.entity.testRedis;
import com.example.demo.model.result;
import com.example.demo.utils.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/redis")
public class redisController {

    private Logger logger= LoggerFactory.getLogger(getClass());

    @Autowired
    private RedisUtil redisUtil;

    @RequestMapping(value = "/test",method = {RequestMethod.POST})
    public result test(@RequestBody testRedis testRedis){
        logger.info("正在测试redis数据传输");
        return result.success(redisUtil.set("hhtest",testRedis));
    }


    @GetMapping("/getTest")
    public result getId(String key){
        return result.success(redisUtil.get(key));
    }



}
